import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class fall here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class fall extends Enemy
{
    Zony z;
    int x,y;
    double velY=0;
    boolean falling=false;
  
    protected void addedToWorld(World world)
    {
        setImage(((it)getWorld()).getFall());  
        Zony it = (Zony) getWorld().getObjects(Zony.class).get(0);
        z=it;
        x=getX();
        y=getY();
        while(((it)getWorld()).ok(x,y)){
            y++;
        }
    }   


    public void act() 
    {
        if(Math.abs(z.getX()-x)<11 && z.getY()>getY() && z.getY()<y)
            falling=true;
        if(falling && velY!=8)velY=velY+.25;
        setLocation(x,(int)(getY()+velY));
        if(!((it)getWorld()).ok(x,getY()+5)){
            double ang;
            for(int f=0;f<5;f++){
                ang = 3.14159*Math.random();
                getWorld().addObject(new projectile(3,2*Math.cos(ang),-2*Math.sin(ang),true),getX(),getY());
            }
            getWorld().removeObject(this);
        }
            
    }  
    
    public void hurt(int x){
    }
    
    public boolean isDeadly(){
        return falling;
    }
    
    
    
    
}
